package uml.behavioral.interpreter;

import uml.behavioral.interpreter.exception.IllegalInstructionException;

/**
 * 解释器--终结符表达式<br>
 * on 2022/12/31 0:23
 */
public class DirectionNode extends AbstractNode {
    private String direction;

    public DirectionNode(String direction) {
        this.direction = direction;
    }

    @Override
    public String interpret() throws IllegalInstructionException {
        switch (this.direction) {
            case "up":
                return "向上";
            case "down":
                return "向下";
            case "left":
                return "向左";
            case "right":
                return "向右";
            default:
                throw new IllegalInstructionException("无效指令"+this.direction);
        }
    }
}
